import * as path from 'path';
import { Storage } from './storage';
import { IBootConfig } from './interface/config';
import * as glob from 'glob';
import "reflect-metadata";


function RegisterControllers(){
    for(const controller of Storage.controllers){
        
    }
}


export function Bootstrap(config : IBootConfig){
    Storage.ROOT_PATH = path.resolve(config.root);
    Storage.APP_PATH = path.resolve(config.root,'app');
    var files;
    try{
        Storage.SCAN_MODE = 'controller';
        files = glob.sync(Storage.APP_PATH + '*/ctrl/*.js');
        console.log(Storage)
        console.log(files);
        if(files){
            for(const file of files){
                require(file);
            }
        }
        Storage.SCAN_MODE = 'model';
        files = glob.sync(Storage.APP_PATH + '*/ml/*.js');
        if(files){
            for(const file of files){

            }
        }

        RegisterControllers();
    }
    catch(e){
        console.log(e);
    }
}